/*   Carina
 *   Copyright (C) 2009 2010 2011  Zdravko Velinov
 *
 *   This program is free software: you can redistribute it and/or modify
 *   it under the terms of the GNU General Public License as published by
 *   the Free Software Foundation, either version 3 of the License, or
 *   (at your option) any later version.
 *
 *   This program is distributed in the hope that it will be useful,
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *   GNU General Public License for more details.
 *
 *   You should have received a copy of the GNU General Public License
 *   along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

#ifndef SETTINGS_DIALOG_HH_
#define SETTINGS_DIALOG_HH_

#include <QDialog>

#include "ui_settings.h"

#include "carina/common/logging.hh"
#include "carina/settings-file.hh"

using namespace Carina;

class ResourceListModel: public QAbstractListModel
{
    Q_OBJECT
public:
    ResourceListModel(QObject* parent = nullptr);

    virtual int rowCount(const QModelIndex& parent=QModelIndex()) const;
    virtual QVariant data(const QModelIndex& index, int role) const;
    virtual QVariant headerData(int section, Qt::Orientation orientation, int role=Qt::DisplayRole) const;

    virtual bool insertRows(int position, int rows, const QModelIndex &index = QModelIndex());
    virtual bool removeRows(int position, int rows, const QModelIndex &index = QModelIndex());

    bool insertRows(QStringList paths, int position=0, const QModelIndex &index = QModelIndex());

    void data(QStringList& paths) const;
private:
    QStringList m_ResourcePaths;
};

class CESettings: public QDialog
{
    Q_OBJECT

    ResourceListModel    m_ResListModel;

    Ui::CarinaSettings   m_Dialog;
    Carina::SettingsFile m_SettingsFile;
public:
    CESettings(QWidget* parent = nullptr);

private:
    void setLoggingLevel(const QString& log_level_name);

private slots:
    void on_AddResBtn_clicked(bool checked=false);
    void on_RemoveResBtn_clicked(bool checked=false);
    void on_LogFileBrowseButton_clicked(bool checked=false);
    
    void on_AddContext_clicked(bool checked=false);
    void on_DeleteContext_clicked(bool checked=false);
    void on_ContextsList_itemSelectionChanged();
    void on_MSAA_valueChanged(int i);
    void on_ScreenHeight_valueChanged(int i);
    void on_ScreenWidth_valueChanged(int i);

    void on_RendererList_currentIndexChanged(const QString& text);
    void on_DefaultLogCheckBox_stateChanged(int state);
    void on_LogLevelList_currentIndexChanged(const QString& text);

    void on_ButtonBox_accepted();
};


#endif /* SETTINGS_DIALOG_HH_ */
